# -*- encoding:utf-8 -*-
# !/usr/bin/env python
'''
    python-0803-02.py
    ======================
    @descript: 推导式
    @copyright:nnz
    @author:dln
    @date: 2021/8/3 19:36
    @version:v1.0
'''
#把一个区间元素保存到列表里
v_range=range(1,6)
v_list=[]
for v_jieguo in v_range:
    v_list.append(v_jieguo)
    pass
print(v_list)
#列表推导式
v_list01=[v_jg for v_jg in v_range]
print(v_list01)
#推导式的嵌套
v_tuple01=('1','2','3')
v_tuple02=('a','b','c')
v_list02=[]
for v_jg01 in v_tuple01:
    for v_jg02 in v_tuple02:
        v_list02.append(v_jg01+v_jg02)
        pass
    print(v_list02)
v_list05=[v_jg01+v_jg02 for v_jg01 in v_tuple01 for v_jg02 in v_tuple02]
print(v_list05)

#求偶数
v_range=range(1,10)
v_list=[]
for v_jg01 in v_range:
    if v_jg01%2==0:
        v_list.append(v_jg01)
    pass
pass
print(v_list)
v_list07=[v_jg01 for v_jg01 in v_range if v_jg01%2==0]
pass
print(v_list07)






